﻿using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace WPNextPhone8.Common
{
    public static class ObservableCollectionEx
    {
        public static void ToObservableCollection<T>(this List<T> list, ObservableCollection<T> observables)
        {
            using (List<T>.Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T current = enumerator.Current;
                    observables.Add(current);
                }
            }
        }

        public static void InserIntoObservableCollection<T>(this List<T> list, ObservableCollection<T> observables)
        {
            list.Reverse();
            using (List<T>.Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T current = enumerator.Current;
                    observables.Insert(0, current);
                }
            }
        }
    }
}
